<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>运动查询</title>
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
    <script type="text/javascript" src="../js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="../laydate/laydate.js"></script>
    <script src="../js/city-picker.data.js"></script>
    <script src="../js/city-picker.js"></script>
    <script src="../js/publicJS.js"></script>
    <style>
        .city-picker-span {
            width: 300px;
        }

        #tr1{
            padding-right: 100px;
        }
    </style>
</head>

<body style="background:#328f46">
<div class="headiv">
    <div class="logotag">
        <a class="logo"><img src="../img/logo.png" width="440" height="65"></a>
        <b class="line"></b>
    </div>
    <a class="username">欢迎登录：<i id="name"></i></a>
    <span class="btnbox">
    	<a class="update" href="/updatePerson" title="修改"></a><a class="exit" href="/logout" title="退出"></a>
    </span>
    <div class="clear" style="height:20px; background:#328f46"></div>
</div>

<div class="messagebox">
    <div class="messageleft">
        <ul class="Fstage">
            <shiro:hasRole name="normalUser">
                <li><a href="#"><em class="e3"></em>健康信息管理
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/healthInfoAdd">健康信息录入</a></li>
                        <li><a href="/healthInfoSelect">健康指数查询</a></li>
                    </ul>
                </li>
                <li><a href="#"><em class="e3"></em>运动信息管理
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/sportIndex">运动信息录入</a></li>
                        <li><a href="/sportIndexSelect">运动信息查询</a></li>
                    </ul>
                </li>
                <li><a href="#"><em class="e3"></em>心理测试
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/testPage">开始测试</a></li>
                        <li><a href="/testrecord">测试记录</a></li>
                    </ul>
                </li>
                <li><a href="#"><em class="e3"></em>健康新闻
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/healthnewsPage">健康新闻</a></li>
                    </ul>
                </li>
            </shiro:hasRole>

            <shiro:hasRole name="admin">
                <li><a href="#"><em class="e3"></em>用户管理
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/userManagement">用户管理</a></li>
                        <li><a href="/userManageSelect">查询所有用户</a></li>
                    </ul>
                </li>
                <li><a href="#"><em class="e3"></em>发布新闻
                    <div class="clear"></div>
                </a>
                    <ul class="Tstage">
                        <li><a href="/releaseNewsPage">发布新闻</a></li>
                    </ul>
                </li>
            </shiro:hasRole>
        </ul>
    </div>
    <!--****************以上不能动，页面固定的东西************************-->
    <div class=" messageright formpage">
        <h2>运动查询</h2><h4>先输入时间然后查询</h4>
        输入时间:<input type="text" id="in">
        <br>
        <br>
        <input type="button" id="se" value="查询" class="greenbtn">
        <br>
        <br>
        <span class="information">
            	<div class="clear" style="height:10px"></div>
                <form class="datable">
                    <table width="100%" border="1" cellpadding="0" cellspacing="0">
                    	<tr id="tr1">
                            <th>跑步</th>
                            <th>跳绳</th>
                            <th>快走</th>
                            <th>仰卧起坐</th>
                            <th>做俯卧撑</th>
                            <th>平板支撑</th>
                            <th>操作</th>
                        </tr>
                        <tbody id="tbody">

                        </tbody>
                    </table>
                </form>
                <div class="clear"></div>
        </span>
        </div>
</div>
</body>

<script>
    laydate.render({
        elem: '#in',
        type: 'date'
    });


    $("#se").click(function () {
        alert("不会出现多点出数据的问题了")
        $.ajax({
            url: "/selectSportIndex",
            type: "post",
            data: {
                date: $("#in").val()
            },
            success: function (result) {
                console.log(result);
                $("#tbody").empty("");
                for (var i in result) {
                    var re = result[i];
                    var run = re.run;
                    var date=re.date;
                    var rope = re.rope;
                    var foot = re.foot;
                    var situp = re.situp;
                    var pushup = re.pushup;
                    var plank = re.plank;
                    var td=("<td>"+run+"</td>" +
                        "<td>"+rope+"</td>" +
                        "<td>"+foot+"</td>" +
                        "<td>"+situp+"</td>" +
                        "<td>"+pushup+"</td>" +
                        "<td>"+plank+"</td>"+
                        "<td><input type='button'  onclick='d()' value='修改'>&nbsp;&nbsp;&nbsp;&nbsp;" +
                        "<input type='button' onclick='de()' value='删除'></td>");
                    $("#tbody").append(td);
                }
            }
        });
    });

    $("#re").click(function () {
        window.location.href = "/re";
    });

    function d() {
        alert("修改");
        window.location.href="/sportIndexSelectUpdate";
    }

    //删除数据
    function de() {
        alert("删除成功,请刷新,在查询这一天,则没有记录了")
        $.ajax({
            url: "/deleteDate",
            type: "post",
            data: {
                date: $("#in").val()
            },
            success: function (result) {
                if (result) {
                    alert("删除成功");
                }
            }
        });
    }


</script>
</html>
